##
#   Project: gmediacatalog - Catalog your media to find them later
#    Author: Fabio Castelli <muflone@vbsimple.net>
# Copyright: 2010 Fabio Castelli
#   License: GPL-2+
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 2 of the License, or (at your option)
#  any later version.
# 
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
# 
# On Debian GNU/Linux systems, the full text of the GNU General Public License
# can be found in the file /usr/share/common-licenses/GPL-2.
##

import gio
import gtk
from preferences import *

theme = gtk.icon_theme_get_default()

def get_icon_from_names(names):
  icon = theme.choose_icon(names, ICON_SIZE, gtk.ICON_LOOKUP_USE_BUILTIN)
  return icon and icon.load_icon() or None
  
def get_file_icon_from_content_type(content_type):
  icon_names = gio.content_type_get_icon(content_type).get_names()
  return get_icon_from_names(icon_names)

def get_stock_icon(stock):
  return theme.load_icon(stock, ICON_SIZE, gtk.ICON_LOOKUP_USE_BUILTIN)
